import { requestHttp } from "@/utils/request";

export interface WeightItem {
  roleId: number;
  weight?: number;
}

export interface EvalWeightGroup {
  id?: number;
  formKey?: string;
  name: string;
  weightList: WeightItem[];
  createTime?: string;
  updateTime?: string;
}

/**
 * 获取权重组列表
 */
export function listEvalWeightGroup(params: EvalWeightGroup) {
  return requestHttp.get<EvalWeightGroup[]>("/form/eval/weightGroup/list", params);
}

/**
 * 获取权重组详情
 * @param id
 */
export function getEvalWeightGroup(id: number | undefined): any {
  return requestHttp.get<EvalWeightGroup>(`/form/eval/weightGroup/${id}`);
}

/**
 * 创建权重组
 * @param data
 */
export function addEvalWeightGroup(data: any) {
  return requestHttp.post("/form/eval/weightGroup/add", data);
}

/**
 * 修改权重组
 * @param data
 */
export function updateEvalWeightGroup(data: any) {
  return requestHttp.post<EvalWeightGroup>("/form/eval/weightGroup/update", data);
}

/**
 * 删除权重组
 * @param id
 */
export function delEvalWeightGroup(id: number | undefined) {
  return requestHttp.post(`/form/eval/weightGroup/delete/${id}`);
}
